package org.agent.aigccore.basic.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import org.agent.aigccore.utils.FormatUtil;

@Slf4j
@Getter
@AllArgsConstructor
public enum DeviceStatusEnum {

    INIT("草稿"),
    ONLINE("在线"),
    OFFLINE("断联"),
    FAIL("失败"),
    DELETE("删除"),
    PAUSE("暂停服务");

    private String code;
    private String desc;

    DeviceStatusEnum(String desc) {
        this.code = name();
        this.desc = desc;
    }

    /**
     * @param code
     * @return
     */
    public static DeviceStatusEnum codeOf(String code) {
        for (DeviceStatusEnum t : DeviceStatusEnum.values()) {
            if (t.getCode().equals(code)) {
                return t;
            }
        }
        throw new IllegalArgumentException(FormatUtil.format("[{0}]不是合法的枚举值", code));
    }
}